﻿<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
</head>
<body>
<table id="tb-prd" width="90%" style="margin-left:30px;margin-top:20px;font-weight: bold;">	
	<tr>
		<td><div id="tb-prd-type"></div></td>
		<td>
			<select id="productsel" class="easyui-combobox" name="visitprocess" style="width:250px;" data-options="required:true">
				<option>请选择</option>
			</select>
		</td>
		<td width="15%">批量&nbsp;&nbsp;<input id="multicheckbox" onclick="change2Multi();" type="checkbox"/></td>
	</tr>		
</table>
<script>
	/**
		设置项目列表单选和多选的切换
	*/
	function change2Multi(){
		if($('#multicheckbox').attr("checked")=="checked"){
			$('#productsel').combobox({multiple : true});
			$('#productsel').combobox('setValue','请选择');				
		}else{
			$('#productsel').combobox({multiple : false}); 
			$('#productsel').combobox('setValue','请选择');	
		}
	}
	
	$("#tb-prd-type").html(currentTab.substr(0,2)+"选择");	
	/**
		获取项目列表
	*/
	getSelectItems();
	function getSelectItems(){
		$('#productsel').combobox({   
			valueField: fieldValue,   
			textField: fieldText,
			onSelect: function(row){
				var newArray = $('#productsel').combobox('getValues');
				if(newArray[0]=='请选择'){
					newArray.shift();
					$('#productsel').combobox('setValues',newArray);
				}
			}
		});  
		var	paramsstr = "{'itemtype':'"+itemtype+"','employeeid':"+oval_user_search+",'visitfeedbackid':"+visitfeedbackid+"}";
		var variable = new Array('__methodName', '__token', 'pagename', 'actionname','__params');
		var value = new Array('wsActionJSON', token, 'p_visitfeedback', 'getfeedbackitems',paramsstr);
		var dataStr = getJsonData(variable, value);
		connectionServlet(dataStr, getItemsCallback);
	}
	
	function getItemsCallback(data){
		if(data.successflag=="true"){	
			if(data.result.allitems == undefined)
				$('#productsel').combobox('loadData',[{text:'请选择'}]);	
			else{
				$('#productsel').combobox('loadData',data.result.allitems);	
			}
		}
	}
	
	/**
		添加所选项目生成项目反馈明细
	*/
	function addSelectItems(){		
		var itemid = $('#productsel').combobox('getValues');
		if(itemid=="请选择"||itemid==""){
			$.messager.alert('提示','请选择一个'+currentTab.substr(0,2)+'！','info');
			return;
		}
		var paramsstr = "{'itemid':'"+itemid+"','itemtype':'"+itemtype+"','employeeid':"+oval_user_search+",'visitfeedbackid':"+visitfeedbackid+"}";
		var variable = new Array('__methodName', '__token', 'pagename', 'actionname','__params');
		var value = new Array('wsActionJSON', token, 'p_visitfeedback', 'savefeedbackitems',paramsstr);
		var dataStr = getJsonData(variable, value);
		connectionServlet(dataStr, addItemsSuccessCallback);
	}
	
	function addItemsSuccessCallback(data){
		if(data.successflag=="true"){				
			var itemid = $('#productsel').combobox('getValue');
			var itemText = $('#productsel').combobox('getText');	
			$('#dlg-prd-sel').dialog('close');	
			$.messager.show({
				title:'提示',
				msg: '数据添加成功！',
				timeout:3000,
				showType:'slide'
			});
			getItemDatas();
			if($('#multicheckbox').attr("checked")!="checked")getItemDetail(itemid,itemText);
		}
	}
</script>
<body>
<html>